using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Ausy.Silverlight.Survey.QuestionModule.ViewParts
{
    /// <summary>
    /// Cette classe représente l'affichage du Timer
    /// </summary>
    public partial class TimerView : UserControl, ITimerView
    {
        #region Model property

        /// <summary>
        /// Model presentation attaché à la vue TimerView
        /// </summary>
        public ITimerViewModel Model
        {
            get { return this.DataContext as ITimerViewModel; }
            set { this.DataContext = value; }
        }

        #endregion

        #region TimerState Dependency Property

        /// <summary>
        /// Etat d'affichage du Control
        /// </summary>
        public string TimerState
        {
            get { return (string)GetValue(TimerStateProperty); }
            set { SetValue(TimerStateProperty, value); }
        }

        /// <summary>
        /// Etat d'affichage du Control
        /// Using a DependencyProperty as the backing store for State.  This enables animation, styling, binding, etc...
        /// </summary>
        public static readonly DependencyProperty TimerStateProperty = DependencyProperty.Register("TimerState", typeof(string), typeof(TimerView), new PropertyMetadata("Normal", new PropertyChangedCallback(OnTimerStatePropertyChanged)));

        /// <summary>
        /// Gestion du Changement d'état d'affichage pour le control
        /// </summary>
        /// <param name="sender">ComponentView</param>
        /// <param name="e">Argument contenant le nouvel état</param>
        static void OnTimerStatePropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            TimerView control = sender as TimerView;
            if (control != null)
            {
                VisualStateManager.GoToState(control, Convert.ToString(e.NewValue), true);
            }
        }

        #endregion

        #region Constructor

        /// <summary>
        /// Constructeur par défaut
        /// </summary>
        public TimerView()
        {
            InitializeComponent();
        }

        #endregion
    }
}
